import cv2
import os
#train labek
train_lines = open('tiny_vid/train_label.txt')
train_label = []
for line in train_lines:
    train_label.append(line.strip('\n'))

#test
test_lines = open('tiny_vid/test_label.txt')
test_label = []
for line in test_lines:
    test_label.append(line.strip('\n'))
#path
bird_path = 'tiny_vid/bird'
bird_lists = os.listdir(bird_path)
bird_ = []
for bird_list in bird_lists:
    bird = os.path.join(bird_path,bird_list)
    bird_ += [bird]
car_path = 'tiny_vid/car'
car_lists = os.listdir(car_path)
car_ = []
for car_list in car_lists:
    car = os.path.join(car_path,car_list)
    car_ += [car]
dog_path = 'tiny_vid/dog'
dog_lists = os.listdir(dog_path)
dog_ = []
for dog_list in dog_lists:
    dog = os.path.join(dog_path,dog_list)
    dog_ += [dog]
lizard_path = 'tiny_vid/lizard'
lizard_lists = os.listdir(lizard_path)
lizard_ = []
for lizard_list in lizard_lists:
    lizard = os.path.join(lizard_path,lizard_list)
    lizard_ += [lizard]
turtle_path = 'tiny_vid/turtle'
turtle_lists = os.listdir(turtle_path)
turtle_ = []
for turtle_list in turtle_lists:
    turtle = os.path.join(turtle_path,turtle_list)
    turtle_ += [turtle]

path = []
path.append(bird_)
path.append(car_)
path.append(dog_)
path.append(lizard_)
path.append(turtle_)

#img = cv2.imread(path[1][1])
# cv2.imshow('img',img)
# cv2.waitKey(0)

train = []
for i in range(len(path)):
    for j in range(150):
        k = i* 150 + j
        t = path[i][j] + ' ' +train_label[k]
        train += [t]

#print(train[1])
train_file=open('tiny_vid/train_data.txt','w')
for line in train:
    train_file.write(line+'\n')
train_file.close()

test = []
for i in range(len(path)):
    for j in range(30):
        k = i* 30 + j
        l = j+150
        t = path[i][l] + ' ' +test_label[k]
        test += [t]

#print(test[1])

test_file=open('tiny_vid/test_data.txt','w')
for line in test:
    test_file.write(line+'\n')
test_file.close()